import request from '@/utils/request'

import qs from 'qs'
// 用户注册
export const register = data => {
    return request({
        method: 'POST',
        url: '/user/create',
        headers: {
            'Content-Type': 'multipart/form-data'
        },
        // data用来设置post请求体
        data
    })
}

// 用户登录
export  const login = data => {
        return request({
            method: 'POST',
            url: '/user/login',
            headers: {
                'Content-Type': 'multipart/form-data'
            },
            // data用来设置post请求体
            data
        })
    }
    // 退出登录
export const loginout = data => {
    return request({
        method: 'POST',
        url: '/user/logout',
        // data用来设置post请求体
        data
    })
}

// 获取用户信息
export const getUserProfile = data => {
    // const user = JSON.parse(window.localStorage.getItem('user'))

    return request({
        method: 'POST',
        url: '/userHome/LemonInfo',
        data
    })
}

// 更新用户接口
export const updateUserProfile = data => {
    return request({
        method: 'POST',
        url: '/userHome/updateLemon',
        headers: {
            'Content-Type': 'multipart/form-data'
        },
        data
    })
}

// 修改用户头像
export const updateUserImg = data => {
    return request({
        method: 'POST',
        url: '/userHome/updateAvatar',
        data,
    })
}

// 修改密码
export const updatePassword = data => {
    return request({
        method: 'POST',
        url: '/userHome/updatePassword',
        headers: {
            'Content-Type': 'multipart/form-data'
        },
        data,
    })
}

// 修改手机号码
export const updatePhone = data => {
    return request({
        method: 'POST',
        url: '/userHome/updatePhoneNumber',
        headers: {
            'Content-Type': 'multipart/form-data'
        },
        data,
    })
}

// 修改邮箱
export const updateEmail = data => {
    return request({
        method: 'POST',
        url: '/userHome/sendEmail',
        data,
        headers: {
            'Content-Type': 'multipart/form-data'
        },
    })
}
